<?php

// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', preg_replace('|\Smodules\Smod_.*?\Sajax.php|i', '', __FILE__));
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');

$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$user_id = $user->id;
$objects = JRequest::getVar("objects",null,"post");

$db->setQuery("delete from `wed_tools` where `user_id` = '$user_id'");
$db->query();

$query = "insert into `wed_tools` values ";
if ($objects) {
	foreach ($objects as $key=>$object) {
		$query .= "(NULL,'$user_id','$object[name]','$object[count]','$object[price]','$object[section]','$object[fixed]')";
		if ($key < count($objects) - 1)
			$query .= ", ";
	}
	
	$db->setQuery($query);
	if ($db->query()) {
		echo 1;
	}
}

exit();

?>